
package com.insigma.business.qrcode.soldier.service.impl;


import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.soldier.dao.PlacementSoldierAspirationDao;
import com.insigma.business.qrcode.soldier.dto.PlacementSoldierAspirationBSearcher;
import com.insigma.business.qrcode.soldier.dto.SequenceNameConstant;
import com.insigma.business.qrcode.soldier.entity.PlacementSoldierAspirationDO;
import com.insigma.business.qrcode.soldier.service.PlacementSoldierAspirationService;
import com.insigma.business.qrcode.soldier.service.PlacementSoldierInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("placementSoldierAspirationService")
public class PlacementSoldierAspirationServiceImpl implements PlacementSoldierAspirationService {

    @Autowired(required = false)
    private PlacementSoldierAspirationDao placementSoldierAspirationDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    @Autowired
    private PlacementSoldierInfoService placementSoldierInfoService;

    
    @Override
    public List<PlacementSoldierAspirationDO> search(final PlacementSoldierAspirationBSearcher placementSoldierAspirationBSearcher) {
        return placementSoldierAspirationDao.search(placementSoldierAspirationBSearcher);
    }
   
    @Override
    public PlacementSoldierAspirationDO get(final String id){
        return placementSoldierAspirationDao.get(id);
    }

    
    @Override
    public Integer insert(final PlacementSoldierAspirationDO placementSoldierAspirationDO){
        placementSoldierAspirationDO.setId(sequenceGenerator.genKey(SequenceNameConstant.PLACEMENT_SOLDIER_ASPIRATION_ID));
        return placementSoldierAspirationDao.insert(placementSoldierAspirationDO);
    }

    
    @Override
    public Integer update(final PlacementSoldierAspirationDO placementSoldierAspirationDO){
        return placementSoldierAspirationDao.update(placementSoldierAspirationDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId){
        return placementSoldierAspirationDao.delete(id,modifierType,modifierId);
    }

    @Override
    public int countBySoldier(String soldierId) {
        String idCardNo = placementSoldierInfoService.getIdCardNoBySoldierId(soldierId);
        return placementSoldierAspirationDao.countByIdCardNo(idCardNo);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listBySoldier(String soldierId) {
        String idCardNo = placementSoldierInfoService.getIdCardNoBySoldierId(soldierId);
        return placementSoldierAspirationDao.listByIdCardNo(idCardNo);
    }

    @Override
    public List<PlacementSoldierAspirationDO> getByPositionId(String id) {
        return placementSoldierAspirationDao.getByPositionId(id, null);
    }

    @Override
    public List<PlacementSoldierAspirationDO> getByPositionId(String id, String status) {
        return placementSoldierAspirationDao.getByPositionId(id, status);
    }

    @Override
    public Integer batchDeleteBySoldierId(String soldierId,String modifierType,String modifierId) {
        String idCardNo = placementSoldierInfoService.getIdCardNoBySoldierId(soldierId);
        return placementSoldierAspirationDao.batchDeleteByIdCardNo(idCardNo, modifierType, modifierId);
    }

    @Override
    public Integer countByPositionId(String positionId, String status) {
        return placementSoldierAspirationDao.countByPositionId(positionId, status);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listByIdCardNo(String idCardNo) {
        return placementSoldierAspirationDao.listByIdCardNo(idCardNo);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listByIdCardNoAndBatchId(String idCardNo, String batchId) {
        return placementSoldierAspirationDao.listByIdCardNoAndBatchId(idCardNo, batchId);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listByIdCardNoAndType(String idCardNo, String type) {
        return  placementSoldierAspirationDao.listByIdCardNoAndType(idCardNo, type);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listByBatchId(String batchId) {
        return placementSoldierAspirationDao.listByBatchId(batchId);
    }

    @Override
    public List<PlacementSoldierAspirationDO> listByBatchId(String batchId, String status) {
        return placementSoldierAspirationDao.listByBatchIdAndStatus(batchId, status);
    }

    @Override
    public Integer count(PlacementSoldierAspirationBSearcher bSearcher) {
        return  placementSoldierAspirationDao.count(bSearcher);
    }

    @Override
    public PlacementSoldierAspirationDO getByPositionIdAndIdCardNo(String positionId, String idCardNo) {
        return placementSoldierAspirationDao.getByPositionIdAndIdCardNo(positionId, idCardNo);
    }

    @Override
    public PlacementSoldierAspirationDO getLastDeletedThroughAsp(String idCardNo) {
        return placementSoldierAspirationDao.getLastDeletedThroughAsp(idCardNo);
    }

    @Override
    public Integer updateCheckFlag(String placementId, String checkFlag) {
        return placementSoldierAspirationDao.updateCheckFlag(placementId, checkFlag);
    }

}
